<template>
	<view class="classlist">
		<view class="left">
			<scroll-view scroll-y="true" class="scroll">
				<view class="left_ul">
					<view @click="navClick(item)" :class="category.id == item.id ? 'left_li active':'left_li'"
						v-for="(item,index) in navlist" :key="index">
						<view class="imgbox">
							<image :src="item.file_path" mode=""></image>
						</view>
						{{item.name}}
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="right">
			<!-- <view class="top">
				<image :src="category.file_path" class="topbanner" mode="widthFix"></image>
			</view> -->
			<view class="goods">
				<view class="goodsitem" v-for="(item,index) in goodslist" :key='index'
					@click="toPage(`/pages/classlist/orderlist?id=${item.id}`)">
					<image :src="item.file_path" mode=""></image>
					<view class="goodsinfo">
						<view class="name">
							{{item.name}}
						</view>
					</view>
					<text class="num" v-if="item.order_count && item.order_count != 0">{{item.order_count}}</text>
				</view>
			</view>
			<view class="no-list" v-if="goodslist.length==0">
				- 暂无数据 -
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getCategory
	} from "@/api/api.js"
	export default {
		data() {
			return {
				navlist: [],
				goodslist: [],
				last_page: 1,
				page: 1,
				category_id: '',
				category: []
			}
		},
		onLoad() {
			this.getCategory()
		},

		methods: {
			getCategory() {
				getCategory().then(res => {
					if (res.code == 0) {
						this.navlist = res.data
						this.goodslist = this.navlist[0].children
					}
				})
			},
			navClick(item, index) {
				this.goodslist = item.children
			}
		}
	}
</script>

<style lang="scss">
	.classlist {
		display: flex;
		position: relative;
		max-width: 500px;

		.left {
			width: 23%;
			height: calc(100vh - 44px);
			/* #ifdef MP-WEIXIN */
			height: calc(100vh);
			/* #endif */
			box-shadow: 1px 0 4px #050B1880;
			padding-top: 40rpx;
			position: fixed;
			left: 0;
			box-sizing: border-box;
			background: #fff;

			uni-scroll-view {
				height: 100%;
			}

			.left_li {
				text-align: center;
				color: #4f4f4f;
				font-size: 14px;
				display: flex;
				align-items: center;
				justify-content: center;
				flex-direction: column;
				padding: 10px 0;

				.imgbox {
					background: #ffffff80;
					border-radius: 50%;
					padding: 2px;
					width: 40px;
					height: 40px;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 3px;
				}

				image {
					width: 36px;
					height: 36px;
					border-radius: 50%;
				}
			}

			.active {
				color: #fff;
				background: #050B18;
			}
		}

		.right {
			position: relative;
			left: 23%;
			width: 77%;
			/* #ifdef H5 */
			// height: calc(100vh - 94px);
			/* #endif */
			/* #ifndef H5 */
			// height: 100vh;
			/* #endif */
			overflow: scroll;
			box-sizing: border-box;
			padding: 0 8px;
			padding-top: 20px;

			.topbanner {
				width: 94%;
				margin-left: 3%;
				height: 8rem;
			}

			.goods {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;

				.goodsitem {
					display: flex;
					width: 33%;
					margin-bottom: 10px;
					flex-direction: column;
					// background: #fff;
					box-sizing: border-box;
					align-items: center;
					position: relative;

					.num {
						position: absolute;
						right: 10px;
						top: 0;
						background: #F23A3A;
						font-size: 12px;
						width: 20px;
						height: 20px;
						font-size: 12px;
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
						border-radius: 50%;
					}

					image {
						width: 60px;
						height: 60px;
						border-radius: 5px;
					}

					.goodsinfo {
						padding: 3px;
						width: 100%;
						box-sizing: border-box;

						.name {
							margin-top: 5px;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
							font-size: 14px;
							font-weight: bold;
							text-align: center;
							margin-top: 4px;
						}

						.des {
							display: -webkit-box;
							-webkit-line-clamp: 2;
							-webkit-box-orient: vertical;
							overflow: hidden;
							font-size: 12px;
							height: 36px;
							line-height: 18px;
							color: #777;
							margin-top: 5px;
						}

						.price {
							font-size: 12px;
							color: #777;
							display: flex;
							justify-content: space-between;
							align-items: center;

							.sell {
								transform: scale(.9);
							}

							.pricenum {
								color: #F23A3A;
								font-size: 13px;
								font-weight: bold;
							}
						}
					}
				}
			}
		}
	}
</style>